package cn.itheima.service.role.impl;

import cn.itheima.dao.role.RoleDao;
import cn.itheima.domain.Role;
import cn.itheima.service.role.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    //分页全查
    public PageInfo findAll(int pageNum, int pageSize, String company_id) {
        PageHelper.startPage(pageNum,pageSize);
        List<Role> list=roleDao.findAll(company_id);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    //删除角色
    public void delete(String id) {
        roleDao.delete(id);

    }

    //添加角色
    public void edit(Role role) {
        roleDao.edit(role);
    }

    //返回修改的角色
    public Role findById(String id) {
        Role role=   roleDao.findById(id);
        return  role;
    }

    //修改角色
    public void update(Role role) {
        roleDao.update(role);
    }
}
